package com.dyh.quickdemozwei.futureopreate;

import java.util.List;

public  class GroupFutureOperate extends AbstractFutureOperate   {

    protected List<FutureOperate> futureOperates;
    protected boolean[] finishTags;


    public GroupFutureOperate(List<FutureOperate> futureOperates) {
        this.futureOperates = futureOperates;
        finishTags = new boolean[futureOperates.size()];
    }

    @Override
    public boolean finished() {
        for (int i=0;i<finishTags.length;i++){
            if (!finishTags[i]){
                boolean b = futureOperates.get(i).finished();
                if (!b)
                    return false;

                finishTags[i] = b;
            }
        }

        return true;
    }

    @Override
    public Object work(Object param) {
        return new UnsupportedOperationException();
    }

}
